#loadmap.py
import sys
import numpy as np

def maploader(rawmap):
	rm = open(rawmap, "r")
	size = (len(rm.readline())-1)/3
	rm.seek(0)
	themap = np.empty((size, size), object) #themap will be accessed through themap[i,j][z].  [z] is an array, use it's index for paramters.
	
	print size
	i = 0
	j = 0
	lst = [8,8,8]
	count = 0
	for line in rm:
		count = 0
		for n in line:
			if (n !='\n'):
				c = int(n)
				lst[count]=c
				if(count == 2):
					themap[i,j] = lst

					j += 1
					lst = [8,8,8]
					count = 0
				else:
					count += 1
		i +=1
		j =0
		#print i
	rm.close()
	#checkmap
	nm = open("map2", "w")
	nm_cur_line = ""
	for i in range(size):#row
		for j in range(size):#column
			nm_cur_line = nm_cur_line + str(themap[i,j][0]) + str(themap[i,j][1]) + str(themap[i,j][2])
		nm_cur_line = nm_cur_line + "\n"
		nm.write(nm_cur_line)
		nm_cur_line = ""
	nm.close()
	return themap

